package com.jack.leetcode.eachProblem07;

/**
 * Created by zhang_j on 2020/7/24
 */
public class 除数博弈 {

    public static void main(String[] args) {
        System.out.println(divisorGame(3));
        System.out.println(divisorGame(2));
    }

    public static boolean divisorGame(int N) {
        int[] dp = new int[N+1];
        dp[1] = -1;

        for(int i = 2;i <= N;i++){
            for(int j = 1;j <= N/2;j++){
                if(i % j == 0){
                    dp[i] = -dp[i-j] == 1 ? 1 : -1;
                    if(dp[i] == 1){
                        break;
                    }
                }
            }
        }
        return dp[N] == 1;
    }
}
